// -*- C++ -*-

//========================================================================
/**
 * Author   : cuisw <shaovie@gmail.com>
 * Date     : 2009-05-30 21:20
 */
//========================================================================

#ifndef NDK_CIRCULAR_BUFFER_H_
#define NDK_CIRCULAR_BUFFER_H_

#include "ndk/message_block.h"

namespace ndk
{
  /**
   * @class circular_buffer
   *
   * @brief 
   */
  class circular_buffer
  {
  public:
    circular_buffer()
    {
    }

    virtual ~circular_buffer()
    {
    }

    // pop one free message block.
    message_block *pop();

    // pop <n> free message blocks which be chained to a link.
    message_block *pop(size_t n);

    // <mb> is a single message_block or a message block chain.
    void push(message_block *mb);
  };
} // namespace ndk

#endif // NDK_CIRCULAR_BUFFER_H_

